#include "../SypEngine.h"

#ifdef CHECKMEM
#include "../mmgr.h"
#endif

bool GuiPass::runnableOnHardware()
{
	return true;
}

void GuiPass::preDraw()
{
	if(timeDepthCleared != Syp::SypEngine::getSypEngine().getCurrFrameTime())
	{	
		Syp::Renderer::getRenderer().clearDepthBuffer();
		timeDepthCleared = Syp::SypEngine::getSypEngine().getCurrFrameTime();		
	}
	origCam = Syp::SceneManager::getSceneManager().getActiveCamera();
	Syp::SceneManager::getSceneManager().setActiveCamera(guiCam);
	
}

void GuiPass::destroy()
{
	Syp::Camera::destroyCamera(guiCam);
	delete this;
}

void GuiPass::postDraw()
{
	Syp::SceneManager::getSceneManager().setActiveCamera(origCam);	
}

GuiPass::GuiPass():Pass("GuiPass","A Pass designed for HUDs/GUI's. It ensures that objects using this pass will be rendered last.",Syp::GUI),timeDepthCleared(0)
{
	guiCam = Syp::Camera::createCamera();	
	guiCam->setNearClip(-1000.0f);
	guiCam->setFarClip(1000.0f);
	

}
